﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using StructureMap;

namespace WebApp.Initialization
{
    public class ControllerFactory : DefaultControllerFactory
    {
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null) return null;
            var controller = ObjectFactory.GetInstance(controllerType);
            ObjectFactory.BuildUp(controller);

            return (IController)controller;
        }
    }
}